﻿using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

namespace CodeCounsel.SharePoint.RibbonDesigner
{
    [PackageRegistration(UseManagedResourcesOnly = true)]
    [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
    [Guid(GuidList.VSPackageString)]
    [ProvideEditorFactory(typeof(EditorFactory), 114, TrustLevel=__VSEDITORTRUSTLEVEL.ETL_AlwaysTrusted)]
    [ProvideEditorLogicalView(typeof(EditorFactory), VSConstants.LOGVIEWID.Designer_string)]
    public sealed class VSPackage : Package
    {
        EditorFactory _editorFactory;
        
        protected override void Initialize()
        {
            base.Initialize();
            _editorFactory = new EditorFactory();
            RegisterEditorFactory(_editorFactory);
            ToolboxInitialized += new EventHandler(VSPackage_ToolboxInitialized);
            ToolboxUpgraded += new EventHandler(VSPackage_ToolboxUpgraded);
        }

        void VSPackage_ToolboxInitialized(object sender, EventArgs e)
        {
        }

        void VSPackage_ToolboxUpgraded(object sender, EventArgs e)
        {
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_editorFactory != null)
                {
                    ((IDisposable)_editorFactory).Dispose();
                    _editorFactory = null;
                }
            }
            base.Dispose(disposing);
        }
    }
}
